package com.hsyt.pms.sys.dubbo.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.hsyt.pfc.support.rpc.PageResult;
import com.hsyt.pms.api.dto.system.SysStreetDto;
import com.hsyt.pms.api.vo.system.SysStreetVo;
import com.hsyt.pms.orm.sys.SysStreetDao;
import com.hsyt.pms.sys.dubbo.SysUserService;
import com.hsyt.pms.sys.dubbo.SysStreetService;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import com.alibaba.dubbo.config.annotation.Service;
import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName: SysStreetServiceImpl
 * @Description: 街道管理
 * @author wangze@hsyuntai.com
 * @date 2019年2月12日 下午2:45:51
 */
@Slf4j
@Component
@Service(version = "0.0.1", interfaceClass = SysStreetService.class, registry = "pms", group = "pmsSystem", timeout = 3000)
public class SysStreetServiceImpl implements SysStreetService {

    private static final Logger LOGGER = LoggerFactory.getLogger(SysStreetServiceImpl.class);

    @Resource
    private SysStreetDao sysStreetDao;

    @Override
    public void addStreet(SysStreetDto dto) {
        sysStreetDao.insertSelective(dto);
    }

    @Override
    public void updateByPrimaryKeySelective(SysStreetDto dto) {
        sysStreetDao.updateByPrimaryKeySelective(dto);
    }

    @Override
    public int count(SysStreetDto dto) {
        if (dto == null) {
            return 0;
        }
        return sysStreetDao.count(dto);
    }

    @Override
    public PageResult<SysStreetVo> searchPageDataByDto(SysStreetDto dto) {
        Page<?> page = PageHelper.startPage(dto.getPageNumber(), dto.getPageSize(), true);
        List<SysStreetVo> list = sysStreetDao.queryStreetByDto(dto);
        PageResult<SysStreetVo> pageResult = PageResult.create(page.getTotal(), list);
        return pageResult;
    }

}
